home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
015a
/
do_for21.zip
/
DO-FOR.DOC
next >
Wrap
Text File
|
1991-08-18
|
11KB
|
259 lines
DO-FOR Version 2.1
NOTE: This program is offered as a "FREEBIE"
NO donations are requested or accepted. I've used enough other
people's freebies that this is offered as only a partial repayment
for their time and effort. My only request is that if you have
any suggestions, bug reports, or comments (I LOVE comments!),
please drop me a line or leave a message for me on Compuserve
ID # (72317,2751).
You can also write or call me at the address/phone number listed at
the bottom of this documentation.
You might also want to check for another "DO" utility, called DO-ONCE.
This other utility allows you to run a program only once a
day/week/month, automating some of the more common "once in a while"
type disk maintenance chores, etc.
------------------ PURPOSE AND FUNCTION OF PROGRAM ----------------
This program was designed to be a faster and more flexible replacement for
the DOS batch file command FOR. It allows you, in effect, to add a
"wildcard" capability to any program, batch file, or DOS command. It also
gives a more capable set of criteria for choosing a wildcard than the simple
DOS * and ? offer. You can choose by the file attribute or file date
as well as by the standard * and ? criteria; alternately, you can create
a list of files to be operated on.
----------------------------- ENVIRONMENT --------------------------
This program was designed to run on an IBM PC/XT/AT or compatible. It should
also run on the PS/2 without difficulty. It runs under MS-DOS or PC-DOS
version 2.0 or later. It is NOT designed to run under OS/2. In terms of
hardware, it should work on just about anything.
------------------------------- SYNTAX -----------------------------
The syntax of DO-FOR is:
DO-FOR [@date] [flags] filemask command
The special @DATE flag allows you to process and manipulate files
based on the date stamp of the file. The format of the @DATE flag
is best shown by examples. Syntax is:
@+ = Matches if file date is on or after date specified.
@- = Matches if file date is before specified date.
@C = Matches if file date is todays date.
DO-FOR @9-18-89 *.* ECHO `f`e `]`] FILELIST.DAT
will make a listing in FILELIST of all files which have the
date of 9-18-89
DO-FOR @-10-17-87 *.BAK DEL `f`e
will delete all files with an extension of .BAK that are
OLDER than October 10, 1987.
DO-FOR @-C30 *.BAK DEL `f`e
will delete all files with an extension of .BAK that are
OLDER than the Current date, MINUS 30 days.
DO-FOR @+3-14-87 *.* ECHO `f`e `]`] FILELIST
will make a listing in FILELIST of all files that are newer
than March 14, 1987.
The "flags" parameter narrows the match criteria, and allows a more
flexible selection than just the DOS wildcards.
Current flags supported are: /a /r /h /s /f
These flags indicate the file attribute of a possible match.
(File attributes are: Archive Read-Only Hidden System)
The /f parameter allows DO-FOR to take the file names from another
text file, instead of using the DOS wildcard match. See the documentation
below for more information on the /f flag.
Each flag should be followed by either a plus + sign or a minus - sign
to indicate which files should be counted as a wildcard match.
/a+ means only files with the archive bit ON will be selected
/a- means only files with the archive bit OFF will be selected
/r+ means only files marked "read-only" will be selected
/r- means only the files which are NOT "read-only" will be selected
/h+ means only the files which are hidden will be selected
/h- means only NON-hidden files will be selected
/s+ means only the files which are system files will be selected
/s- means only NON-system files will be selected
The /f parameter will allow DO-FOR to get the list of filenames to operate
on from a text file, instead of from DOS.
This will allow you to customize what files DO-FOR will operate on even
further than with the DOS wildcards and other DO-FOR flags.
Example: The file C:\ACCT\CUST.TXT contains a list of files which
need to be backed up every day.
The command: DO-FOR /f C:\ACCT\CUST.TXT COPY `f`e A:`f`e
will parse through that list and copy any filenames it finds there to
the floppy in Drive A.
This parameter may be used with all the other parameters as well.
For example:
The command: DO-FOR /a+ /f C:\ACCT\CUST.TXT COPY `f`e A:`f`e
will do the same as the previous example, but ONLY those files which have the
archive bit set will be copied.
The following substitutions can be made in "command"
`f will be replaced by the filename without extension.
`e will be replaced by a period and the extension
`d will be replaced by the drive (with colon and backslash)
`p will be replaced by the filepath (with trailing backslash)
`[ will be replaced by the < sign
`] will be replaced by the > sign
`^ will be replaced by the | sign
`` will be replaced by a single ` character
Please note that the ` character is a BACKWARDS apostrophe character
--------------------------------------
ERRORLEVEL responses:
If you run DO-FOR without any parameters, it gives a synopsis of the
command syntax, and exits with an ERRORLEVEL of 255.
If you run DO-FOR using the @DATE option, and DO-FOR cannot understand
the date you entered, OR if the date is invalid (like February 29 in a
non-leap year) then DO-FOR will exit with an explanatory message and an
ERRORLEVEL of 1.
------------------------------------
CAUTIONS:
1) Please note (as explained in the "re-direction" section below) that
you should not use a disk-optimizing program WHILE OUTPUT IS BEING
RE-DIRECTED TO A FILE, or cross-linking of file clusters can occur.
----------------------------- EXAMPLES -------------------------------
DO-FOR C:\DOCS\*.PJ WP `D`P`F`E
Runs the WP program for eachfile with the .PJ extension found in the
C:\DOCS\ subdirectory. (as if you typed WP C:\DOCS\*.WP )
DO-FOR C:\DBASE\*.DBF COPY `d`p`f`e C:\DBASE\`f.BAK
will make a copy with a .BAK extension for all of the
.DBF files in the C:\DBASE subdirectory.
DO-FOR *.DOC C:\WP50\CONVERT 6 `f`e `f.WP
will run a CONVERT program for all .DOC files, inserting as the
second parameter the document name with the extension of .WP
DO-FOR /a+ *.DAT COPY `f`e A:\`f`e
will back up onto the A drive floppy any .DAT files which have the
archive bit set (have been modified).
--------------------------------- MORE JUNK --------------------------------
For those command lines which require re-direction, instead of including
the > symbol on the DO-FOR command line (which DOS will interpret as re-
directing the output of DO-FOR, not your program)...you can insert the
following two part symbols:
`] will be replaced with the > symbol.
`[ will be replaced with the < symbol.
`^ will be replaced with the | symbol.
Please note, this is a backwards apostrophe (ASCII character 96), followed
by a right square bracket, left square bracket, or caret mark.
CAUTION: Using a disk-optimizing program while output is being redirected to
a file can cause cross-linkage of file clusters. This has nothing to do with
DO-FOR, but is true whenever such programs are run. This caution is being
included here just to save you some headaches. If you are using such a
program, or any program which *directly* manipulates the File Allocation
Table (FAT) then do NOT re-direct output to a file. (You can still redirect
output to a device such as NUL or PRN without any problems.)
Redirection example: DO-FOR *.PAS `]`] C:\PASFILES.LST
will create a list (in PASFILES.LST) of all files in the
current directory which end with a .PAS extension.
If you have no idea what I'm talking about with re-direction and piping,
that's OK. If you haven't found it necessary to learn these DOS tools yet,
you needn't learn them just for DO-FOR.
----------------------------- HOW DO-FOR WORKS -----------------------------
------------------------ (useless technical details) ------------------------
DO-FOR was written using Borland's Turbo Pascal, Version 6.0
It also makes use of Bob Ainsbury's excellent shareware function library,
the "TechnoJock's Turbo Toolkit." (Yes, I registered it, did you?)
DO-FOR simply does a FindFirst search for a matching filename, based on the
wildcard you supply. (or it takes the file names from a list specified by
the /f parameter) If it finds it, and if it matches any additional flag
criteria, it will add that filename to its list. It then checks the list
for duplicates, and then it will load a secondary copy of COMMAND.COM and
pass it the command line you have entered, first making any substitutions
as requested in the command line with the ` commands.
One former problem which was fixed in Version 2.0 happened if the program
that was executed modified the directory, then the "findnext" function used
by DOS could have been be messed up, and might have "found" a file twice, and
executed the command line twice for that file.
The source code for DO-FOR is not available for distribution because
1) I don't want everyone making fun of my code (once again, I'll admit it).
2) I don't want to have to comment every line of the source.
3) It uses several of my own units for date and string handling which I
do not want released.
4) I don't want J. Random Dufus to modify (and mess up) the program.
That's why it's copyrighted.
- - - - - - - - - - -
If you have any questions, problems, or suggestions, please let me know. If I
can make the program more useful for you, also let me know.
Glenn Snow
PO Box 655
Mundelein, IL 60060
(708) 566-4079 (voice only, please)
(708) 566-4083 BBS
CIS 72317,2751
-------------------------------------------------
Version history
1.0 -- Original DO-FOR, written in Turbo Pascal 4.0 (October, 1989)
(Yes, I know, I should get Turbo Pascal 5.5, but I haven't gotten
around to it yet.)
1.1 -- Allows re-direction within command line
1.2 -- Added /q Quiet switch, for an uncluttered screen.
2.0 -- Added an array of filenames (300) processed, so that no duplicates are
repeated when DOS "findnext" function gets messed up...Isn't DOS fun?
(Oh, and I finally got Turbo Pascal 6) (June, 1991)
Also added the ability to parse the filenames from a text file (the
/f parameter) for further utility.
2.1 -- Added the /m parameter so that users of 4DOS can avoid the reserved `
character, and change it to anything they want. (Thanks to Rick Charnes
for the suggestion)
--------------------------- END OF DOCUMENTATION ------------------------